#ifndef __AS_IMAGE_RES_MGR__H__
#define __AS_IMAGE_RES_MGR__H__

#include "..\control\ASImage.h"

#ifdef AS_USE_IMAGE_RESOURCE_MANAGER

/*this image resource support max images*/
#define AS_IMAGE_RES_MAX  64

typedef struct
{
    ASINT if_used;
    ASWCHAR path[AS_IMAGE_PATH_LEN];
    as_image_src_type type;
    as_res_info res_info;
    ASINT ref_counts;
} as_image_res_info;


struct _as_image_resmgr;
typedef struct _as_image_resmgr as_image_resmgr;
struct _as_image_resmgr
{
    /* attributes */
    ASINT if_inited;
    as_image_res_info infos[AS_IMAGE_RES_MAX];

    /* methods */

    /*
     *	[description] add an image info to res_mgr,if it's a new info,we will load it into memory,else we just add reference counts.
     *  [param] self : res_mgr
     *  [param] type : image source type
     *  [param] path : image path in ucs2
     *  [return] ASINT : canvas handler of this image info
     */
    ASINT (*add)(as_image_resmgr* self, as_image_src_type type, ASWSTR path, as_res_info* out_p);

    /*
     *	[description] if you load an image into memory yourself,you can use this function to add info into res_mgr
     *  [param] self : res_mgr
     *  [param] path : image path in ucs2
     *  [param] canvas_hdlr : canvas handler of this image
     *  [param] type : which type of this image
     *  [return] ASINT : canvas handler of this image info
     */
    //ASINT (*add_existed)(as_image_resmgr* self, ASWSTR path, ASINT canvas_hdlr, as_image_src_type type);

    /*
     *	[description] you can resize an image
     *  [param] self : res_mgr
     *  [param] path : image path in ucs2
     *  [param] w : width you want to resize
     *  [param] h : height you want to resize
     *  [return] ASINT : canvas handler of this image info
     */
    //ASINT (*resize)(as_image_resmgr* self, ASWSTR path, ASINT w, ASINT h);

    /*
     *	[description] delete an image info by image path
     *  [param] self : res_mgr
     *  [param] path : image path in ucs2
     *  [return] as_ret : AS_OK or error codes.
     */
    as_ret (*delete_by_path)(as_image_resmgr* self, ASWSTR path);

    /*
     *	[description] delete an image info by canvas handler
     *  [param] self : res_mgr
     *  [param] canvas_hdlr : canvas handler of image which you want to delete
     *  [return] as_ret : AS_OK or error codes.
     */
    //as_ret (*delete_by_hdlr)(as_image_resmgr* self, ASINT canvas_hdlr);

    /*
     *	[description] delete the canvas handler just for reload it
     *  [param] self : res_mgr
     *  [param] canvas_hdlr : canvas handler of image which you want to reload
     *  [return] as_ret : AS_OK or error codes.
     */
    //as_ret (*delete_canvas_for_reload)(as_image_resmgr* self, ASINT canvas_hdlr);

    /*
     *	[description] get index of the image through the path
     *  [param] self : res_mgr
     *  [param] path : image path in usc2
     *  [return] ASINT : the index
     */
    ASINT (*get_idx_by_path)(as_image_resmgr* self, ASWSTR path);

    /*
     *	[description] release the instance of res_mgr
     *  [param] self : res_mgr
     */
    void (*release)(as_image_resmgr* self);
};

/*
 *	[description] get the instance of res_mgr
 *  [return] as_image_resmgr* : the pointer of res_mgr
 */
as_image_resmgr* as_image_resmgr_get_instance(void);

#endif//AS_USE_IMAGE_RESOURCE_MANAGER

#endif//__AS_IMAGE_RES_MGR__H__